/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __VVERTEXBUFFERMANAGER_H__
#define __VVERTEXBUFFERMANAGER_H__

#include "./vVertexBuffer.h"
#include "../../Macros/vMemoryMacros.h"

namespace Vendetta {
	class vVertexBufferManager {
		friend class vApi;
	public:
		/*! \enum eVertexBufferType
		 *
		 *  \brief Specifies the type of vertex buffer to be used.
		 *
		 *	There are 2 types of vertex buffer:
		 *	1. VVBT_SOFTWARE - it uses basic API functions to store and use vertex buffer.
		 *	2. VVBT_HARDWARE - it uses GPU to store and use vertex buffer. If You going to
		 *					   use shaders You must use this type.
		 */
		enum eVertexBufferType {
			VVBT_SOFTWARE,			//! Software vertex storage and use.
			VVBT_HARDWARE			//! Hardware vertex storage and use.
		};
	public:
		virtual ~vVertexBufferManager();

		virtual vVertexBuffer* CreateVertexBuffer(const vArray<vPoint3D>& vertices,
			const vArray<vPoint2D>& texCoords, const vArray<vPoint3D>& normals,
			const vArray<vColor>& colors, vUInt32 ui32Format, 
			vVertexBuffer::eVertexBufferPrimitiveType ePrimitiveType,
			eVertexBufferType eType,
			vVertexBuffer::eVertexBufferUsage eUsage);
		
		virtual vVertexBuffer* CreateVertexBuffer(const vPoint3D* pVertices,
			const vPoint2D* pTexCoords, const vPoint3D* pNormals,
			const vColor* pColors, vUInt uiVertexCount, vUInt uiTexCoordCount, 
			vUInt uiNormalCount, vUInt uiColorCount, vUInt32 ui32Format, 
			vVertexBuffer::eVertexBufferPrimitiveType ePrimitiveType,
			eVertexBufferType eType,
			vVertexBuffer::eVertexBufferUsage eUsage);
			
			
		virtual vBool DeleteVertexBuffer(vVertexBuffer* pBuffer);
	protected:
		vVertexBufferManager();
		
		vBool checkIfValid(const vArray<vPoint3D>& vertices,
			const vArray<vPoint2D>& texCoords, const vArray<vPoint3D>& normals,
			const vArray<vColor>& colors, vUInt32 ui32Format,
			vVertexBuffer::eVertexBufferPrimitiveType ePrimitiveType);
			
		vBool checkIfValid(const vPoint3D* pVertices,
			const vPoint2D* pTexCoords, const vPoint3D* pNormals,
			const vColor* pColors, vUInt uiVertexCount, vUInt uiTexCoordCount, 
			vUInt uiNormalCount, vUInt uiColorCount, vUInt32 ui32Format, 
			vVertexBuffer::eVertexBufferPrimitiveType ePrimitiveType);
			
		virtual vVertexBuffer* apiNewVertexBuffer(vUInt uiSize, vUInt32 ui32Format, 
			vVertexBuffer::eVertexBufferPrimitiveType ePrimitiveType,
			eVertexBufferType eType,
			vVertexBuffer::eVertexBufferUsage eUsage) = 0;
		
	protected:
		//! Disabled - if You call this You get exception.
		vVertexBufferManager(const vVertexBufferManager& buffer);
		
		//! Disabled - if You call this You get exception.
		vVertexBufferManager& operator=(const vVertexBufferManager& buffer);
		
	protected:
		vArray<vVertexBuffer*> mBuffers;
	
	};
}

#endif // __VVERTEXBUFFERMANAGER_H__